import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_learn_vi/src/bean/bean_train.dart';
import 'package:flutter_learn_vi/src/bean/bean_user.dart';
import 'package:flutter_learn_vi/src/common/user_helper.dart';
import 'package:flutter_learn_vi/src/page/train/custom_train_bottom_appbar.dart';
import 'package:flutter_learn_vi/src/page/train/train_tab_details1_page.dart';
import 'package:flutter_learn_vi/src/page/train/train_tab_details2_student_page.dart';
import 'package:flutter_learn_vi/src/page/train/train_tab_details2_teacher_page.dart';
import 'package:flutter_learn_vi/src/page/train/train_tab_details3_student_page.dart';
import 'package:flutter_learn_vi/src/page/train/train_tab_details3_teacher_page.dart';

/// 创建人： Created by zhaolong
/// 创建时间：Created by  on 2021/1/16.
///
/// 可关注公众号：我的大前端生涯   获取最新技术分享
/// 可关注网易云课堂：https://study.163.com/instructor/1021406098.htm
/// 可关注博客：https://blog.csdn.net/zl18603543572
///
/// 代码清单
///代码清单
class TrainListDetailsPage extends StatefulWidget {
  final TrainApproveBean approveBean;

  const TrainListDetailsPage({Key key, this.approveBean}) : super(key: key);

  @override
  _TrainListDetailsPageState createState() => _TrainListDetailsPageState();
}

class _TrainListDetailsPageState extends State<TrainListDetailsPage> {
  //[PageView]使用的控制器
  PageController _pageController = PageController();

  @override
  Widget build(BuildContext context) {
    UserBean userBean = UserHelper.getInstance.userBean;

    //Scaffold 用来搭建页面的主体结构
    return Scaffold(
      backgroundColor: Color(0xfff5f4f4),
      //页面的主内容区
      //可以是单独的StatefulWidget 也可以是当前页面构建的如Text文本组件
      body: Stack(
        children: [
          Positioned.fill(
            child: PageView(
              //设置PageView不可滑动切换
              physics: NeverScrollableScrollPhysics(),
              //PageView的控制器
              controller: _pageController,
              //PageView中的三个子页面
              children: [
                TrainTabDetails1Page(
                  approveBean: widget.approveBean,
                ),
                userBean.userType == 12
                    ? TrainTabDetails2TeacherPage(
                        approveBean: widget.approveBean,
                      )
                    : TrainTabDetails2StudentPage(
                        approveBean: widget.approveBean,
                      ),
                userBean.userType == 12
                    ? TrainTabDetails3TeacherPage(
                        approveBean: widget.approveBean,
                      )
                    : TrainTabDetails3StudentPage(
                        approveBean: widget.approveBean,
                      )
              ],
            ),
          ),
          Positioned(
            left: 0,
            top: 34,
            child: InkWell(
              onTap: () {
                Navigator.of(context).pop();
              },
              child: Row(
                mainAxisSize: MainAxisSize.min,
                children: [
                  SizedBox(
                    width: 8,
                  ),
                  Icon(Icons.close),
                  SizedBox(
                    width: 8,
                  ),
                  Text("关闭"),
                ],
              ),
            ),
          )
        ],
      ),
      //底部导航栏
      bottomNavigationBar: BottomAppBar(
        //背景颜色
        color: Colors.white,
        //自定义底部菜单栏
        child: CustomTrainBottomAppBar(
          clickCallBack: (int index) {
            _pageController.jumpToPage(index);
          },
        ),
      ),
    );
  }
}
